<template>
  <div class="avue-sidebar">
    <logo></logo>
    <el-scrollbar style="height: 100%">
      <div v-if="validatenull(menu)" class="avue-sidebar--tip">
        {{ $t("menuTip") }}
      </div>
      <el-menu
        unique-opened
        :default-active="nowTagValue"
        mode="vertical"
        :show-timeout="200"
        :collapse="keyCollapse"
      >
        <sidebar-item
          :menu="menu"
          :screen="screen"
          first
          :props="website.menu.props"
          :collapse="keyCollapse"
        ></sidebar-item>
      </el-menu>
      <div class="wechat" v-if="false">
        <div class="wechat-title"><span>关注公众号：</span></div>
        <img src="../img/wechat.jpg" alt="" />
        <div class="wechat-title" @click="goSkip({ name: '心理室建设' })">
          <span>心理室建设方案</span><i class="el-icon-arrow-right"></i>
        </div>
      </div>
    </el-scrollbar>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import logo from "../logo";
import sidebarItem from "./sidebarItem";
export default {
  name: "sidebar",
  components: { sidebarItem, logo },
  data() {
    return {};
  },
  created() {
    this.$store.dispatch("GetMenu").then((data) => {
      if (data.length === 0) return;
      this.$router.$avueRouter.formatRoutes(data, true);
    });
  },
  computed: {
    ...mapGetters(["website", "menu", "tag", "keyCollapse", "screen"]),
    nowTagValue: function () {
      return this.$router.$avueRouter.getValue(this.$route);
    },
  },
  mounted() {},
  methods: {
    goSkip(item) {
      this.$router.push({
        name: item.name,
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.wechat {
  width: 240px;
  height: 200px;
  text-align: center;
  position: fixed;
  left: 0px;
  bottom: 50px;

  .wechat-title {
    color: white;
    padding: 15px 0;
    font-weight: bold;
    text-align: left;

    > span {
      padding-left: 20px;
    }
  }

  .wechat-title2 {
    color: white;
    padding: 15px 0;

    span {
      cursor: pointer;
      padding-right: 10px;
    }
  }

  img {
    width: 100px;
  }
}
</style>
